package string;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.junit.Test;

import java.util.List;
import java.util.Random;
import java.util.Set;

public class StringShuxueyunsuan {

  public static void main(String[] args) {

    String a = "a";

    while (true) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      a += "a ";
    }
  }

  @Test
  public void test1() {
    for (int i = 0; i < 1000; i++) {
      int v = new Random().nextInt(1000);
      String a = "aaaa";
      Set<Integer> list = Sets.newHashSet();
      list.add((a + v).hashCode());
      list.add((a + v).intern().hashCode());
      System.gc();
      list.add((a + v).intern().hashCode());
      if (list.size() > 1)
        for (Integer integer : list) {
          System.out.print(integer);
        }
//      System.out.println();
    }


  }


}
